Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host-containers: migrate to use config file #3777

Merged

Conversation

sam-berning
Copy link
Contributor

@sam-berning sam-berning commented Feb 14, 2024

Issue number:

Closes #3627

Description of changes:

Removes dependency on the API model from host-containers by changing it to use a config file rendered from the settings.

Testing done:

  • Ran cargo +nightly udeps to ensure all unused dependencies have been removed
  • Pass the settings on first boot via userdata. Verify config.
  • cat /etc/os-release record your build ID include commit sha, record this
  • Use apiclient to update relevant settings at runtime. Verify config was updated correctly.
  • Downgrade to older version.
    • verify connectivity
    • cat /etc/os-release to verify lower version
    • verify that migrations have changed the metadata/settings as expected (i.e. they are gone from the datastore, or lists have been changed back)
  • Upgrade to newer version.
    • verify connectivity
    • cat /etc/os-release to verify version
    • verify config file

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@sam-berning sam-berning force-pushed the host-containers-config-file branch 2 times, most recently from 1076397 to 903c5ea Compare February 14, 2024 23:32
@sam-berning
Copy link
Contributor Author

^ update template to {{{ everything to keep it consistent with what we expected when reading directly from the API

sources/api/host-containers/src/config.rs Outdated Show resolved Hide resolved
packages/os/os.spec Show resolved Hide resolved
sources/api/host-containers/Cargo.toml Show resolved Hide resolved
sources/api/host-containers/src/main.rs Show resolved Hide resolved
sources/api/host-containers/src/main.rs Outdated Show resolved Hide resolved
sources/api/host-containers/src/main.rs Show resolved Hide resolved
@sam-berning sam-berning self-assigned this Feb 15, 2024
@sam-berning
Copy link
Contributor Author

^ address @webern's comments

@sam-berning sam-berning force-pushed the host-containers-config-file branch 2 times, most recently from 3346ec3 to 9dad1a7 Compare February 28, 2024 22:53
Copy link
Contributor

@webern webern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching my review status as it needs a rebase and then needs testing. Here is the test plan that we have suggested, this should be pasted into the testing section of the PR description

- [ ] Ran `cargo +nightly udeps` to ensure all unused dependencies have been removed
- [ ] Pass the settings on first boot via userdata. Verify config.
- [ ] cat /etc/os-release record your build ID include commit sha, record this
- [ ] Use apiclient to update relevant settings at runtime. Verify config was updated correctly.
- [ ] Downgrade to older version. 
  - [ ] verify connectivity
  - [ ] cat /etc/os-release to verify lower version
  - [ ] verify that migrations have changed the metadata/settings as expected (i.e. they are gone from the datastore, or lists have been changed back)
- [ ] Upgrade to newer version.
  - [ ] verify connectivity
  - [ ] cat /etc/os-release to verify version
  - [ ] verify config file

@sam-berning sam-berning marked this pull request as draft March 5, 2024 01:16
This removes the dependency on calling the Settings API. It instead
depends on a config file (defaults to
/etc/host-containers/host-containers.toml)

Signed-off-by: Sam Berning <[email protected]>
@sam-berning
Copy link
Contributor Author

^ testing summary:

  • Ran cargo +nightly udeps to ensure all unused dependencies have been removed

  • Pass the settings on first boot via userdata. Verify config.

    Enabled and configured the admin container in user data. cat'd the config file at /etc/host-containers/host-containers.toml and it contained the user data.

  • cat /etc/os-release record your build ID include commit sha, record this

bash-5.1# cat /etc/os-release
...
VERSION="1.19.3 (aws-dev)"
...
BUILD_ID=1e9e8f3a
...
  • Use apiclient to update relevant settings at runtime. Verify config was updated correctly.
bash-5.1# apiclient set --json '{"settings": {"host-containers": {"foo": {"source": "public.ecr.aws/bottlerocket/bottlerocket-admin:v0.11.5", "enabled": true, "superpowered": true}}}}'
bash-5.1# cat /etc/host-containers/host-containers.toml
...
[host-containers."foo"]
source = "public.ecr.aws/bottlerocket/bottlerocket-admin:v0.11.5"
enabled = true
superpowered = true
  • Downgrade to older version.
    • verify connectivity
    • cat /etc/os-release to verify lower version
    • verify that migrations have changed the metadata/settings as expected (i.e. they are gone from the datastore, or lists have been changed back)
bash-5.1# updog update -i 1.19.2 -r -n
Starting update to 1.19.2
Reboot scheduled for Wed 2024-03-06 01:53:29 UTC, use 'shutdown -c' to cancel.
Update applied: aws-dev 1.19.2
# after reboot, was able to ssh successfully
bash-5.1# cat /etc/os-release
...
VERSION="1.19.2 (aws-dev)"
...
# no host-containers-toml config file, and it is removed from host-containers config files
bash-5.1# ls /var/lib/bottlerocket/datastore/current/live/configuration-files/ 
certdog-toml   containerd-config-toml  hostname				   metricdog-toml  motd		proxy-env
cfsignal-toml  docker-daemon-config    hosts				   modprobe-conf   netdog-toml	updog-toml
chrony-conf    host-ctr-toml	       log4j-hotpatch-enabled-log-message  modules-load    oci-hooks
bash-5.1# cat /var/lib/bottlerocket/datastore/current/live/services/host-containers/configuration-files 
["host-ctr-toml"]
  • Upgrade to newer version.
    • verify connectivity
    • cat /etc/os-release to verify version
    • verify config file
bash-5.1# updog update -i 1.19.3 -r -n
Starting update to 1.19.3
Reboot scheduled for Wed 2024-03-06 01:58:04 UTC, use 'shutdown -c' to cancel.
Update applied: aws-dev 1.19.3
# after reboot, was able to ssh successfully
bash-5.1# cat /etc/os-release
...
VERSION="1.19.3 (aws-dev)"
...
bash-5.1# cat /etc/host-containers/host-containers.toml
# looked as expected!

@sam-berning sam-berning marked this pull request as ready for review March 6, 2024 02:34
@sam-berning sam-berning requested a review from webern March 6, 2024 02:34
Copy link
Contributor

@webern webern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@jmt-lab
Copy link
Contributor

jmt-lab commented Mar 6, 2024

Looks good to me as well

@sam-berning sam-berning merged commit 8065f6b into bottlerocket-os:develop Mar 6, 2024
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OOTB: Remove model dependency from host-containers
3 participants